var PUB = {
    isLogin: false,
    actionUrl: "http://www.pomoho.com/api/userapi.asmx/UserLogin",
    Init: function (callback)
    {
        baseurl = 'http://video.pomoho.com/do';
        var n = this.cookie('LoginInfo');
        if (n)
        {
            var arr = n.split('$***$');
            _space_user = {
                uid: arr[0].replace('LoginInfo=', ''),
                nick: arr[1],
                spacename: unescape(arr[2]),
                username: arr[3],
                newmsg: 0
            };
            isLogin = true;
            if (typeof (callback) != 'undefined')
            {
                callback(_space_user);
            }
        } else
        {
            isLogin = false;
            if (typeof (callback) != 'undefined')
            {
                callback(null);
            }
        };
        if ('undefined' == typeof (callback) || callback)
        {
            if (isLogin)
            {
                this.islogin();
            } else
            {
                this.unlogin();
            }
        };
        PUB.loadScript('http://live.pomoho.com/getxmldata.aspx?type=2&ids=' + flvid + '_999');
        PUB.commentReply('#Comment');
        PUB.emotionWR('#Comment');
        PUB.emotion();
    },
    ajaxLoad: function (type, url, data, dataType, d, fun)
    {
        $.ajax({
            type: type,
            url: url,
            data: data,
            dataType: dataType,
            beforeSend: function ()
            {
                if (typeof (d) != 'undefined' && d.length > 0) $(d).show();
            },
            complete: function ()
            {
                if (typeof (d) != 'undefined' && d.length > 0) $(d).hide();
            },
            success: function (data)
            {
                _getDATA = data;
                fun.call(this);
            }
        });
    },
    loadScript: function (url, options)
    {
        var setting = {
            random: true
        };
        if (options)
        {
            $.extend(setting, options);
        }
        var f = document.createElement('script');
        f.type = 'text/javascript';
        var d = new Date();
        if (setting.random)
        {
            if (url.match(/.*\?./))
            {
                url = url + '&random=' + d.getTime() + parseInt(Math.random() * 10000);
            } else
            {
                url = url + '?random=' + d.getTime() + parseInt(Math.random() * 10000);
            }
        }
        f.src = url;
        $('head')[0].appendChild(f);
    },
    logDiv: function (sType, sTarget, sUrl, callback)
    {
        var str = '';
        if ($.browser.msie && String($('body').attr('id')) == 'B-Upload')
        {
            str += '';
        } else
        {
            str += '<div id="zhezhao"></div>';
        }
        str += ' <div id="Prompt" class="prompt">';
        str += '    <div class="k log_v">';
        str += '      <div class="meat">';
        str += '        <div class="close"><a title="关闭"></a></div>';
        str += '        <h3></h3>';
        str += '        <p class="p2">您的帐号：';
        str += '          <input id="uidName" type="text" onkeypress="PUB.submitF(event)" />';
        str += '        </p>';
        str += '        <p class="p2">登录密码：';
        str += '          <input id="uidPwd" type="password" onkeypress="PUB.submitF(event)" />';
        str += '          <a href="http://b.pomoho.com/ui/findpassword.aspx" target="_blank">忘记密码</a></p>';
        str += '        <p class="pbt">';
        str += '          <input id="btnlog" class="log" type="submit" value="登录" />';
        str += '          <input id="reg" class="log" type="button" value="注册" />';
        str += '        </p>';
        str += '      </div>';
        str += '    </div>';
        str += '  </div>';
        $("body").prepend(str);
        if ($.browser.msie && String($('body').attr('id')) == 'B-Upload')
        {
            Pra.ui.overlay();
        }
        $("#Prompt .close a").bind("click", PUB.closeDiv);
        $("#btnlog").click(function ()
        {
            PUB.login(sType, sTarget, sUrl, callback);
        });
        $("#reg").click(function ()
        {
            window.open('http://b.pomoho.com/ui/reg_v2.aspx');
        });
    },
    showLogDiv: function (sType, sTarget, sUrl, callback)
    {
        if (String($('body').attr('id')) == 'B-Upload')
        {
            this.logDiv(sType, sTarget, sUrl, callback);
        } else if (!$("#Prompt").length)
        {
            this.logDiv(sType, sTarget, sUrl, callback);
        }
        var doc = document;
        var docElement = doc.documentElement;
        var sHeight = docElement.clientHeight;
        var dH = docElement.scrollHeight > sHeight ? docElement.scrollHeight : sHeight;
        var scH = docElement.scrollTop >= 0 ? (docElement.scrollTop + sHeight / 2) : sHeight;
        var h = scH - $("#Prompt").height() / 2;
        var w = docElement.clientWidth / 2 - $("#Prompt").width() / 2;
        $("#zhezhao").height(dH).show();
        $("#Prompt").css({
            top: h,
            left: w
        });
    },
    loginfo: function (sType, sTarget, sUrl, callback)
    {
        this.showLogDiv(sType, sTarget, sUrl, callback);
        $("#Prompt").show();
        $("#Prompt .k")[0].className = "k log_v";
        $('#uidName').focus();
        if (document.attachEvent)
        {
            document.attachEvent('onkeyup', PUB.EXC);
        } else
        {
            document.addEventListener('keyup', PUB.EXC, false)
        }
    },
    LoginfoClick: function (callback, sType, sTarget, sUrl)
    {
        this.loginfo(sType, sTarget, sUrl, callback);
    },
    logCall: function (callback)
    {
        window.location.href = "http://b.pomoho.com/manage/index.aspx";
    },
    unlogin: function ()
    {
        var str = '';
        str += '<div class="row" id="topNav">';
        str += '<a title="登录" href="http://b.pomoho.com/ui/login.aspx"  target="_blank" >登录</a>';
        str += '<a title="注册" href="http://b.pomoho.com/ui/reg_v2.aspx" target="_blank">注册</a>';
        str += '</div>';
        $("#top_Nav #L").html(str);
    },
    localTime: function ()
    {
        var time = new Date();
        var hour = time.getHours();
        var t_time = ($.browser.msie) ? String(time).split(" ")[3].substr(0, 5) : String(time).split(" ")[4].substr(0, 5);
        switch (hour)
        {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                t_time = '早上好';
                break;
            case 8:
            case 9:
            case 10:
            case 11:
                t_time = '上午好';
                break;
            case 12:
                t_time = '中午好';
                break;
            case 13:
            case 14:
            case 15:
            case 16:
            case 17:
                t_time = '下午好';
                break;
            case 18:
            case 19:
            case 20:
            case 21:
            case 22:
            case 23:
                t_time = '晚上好';
                break;
        }
        return t_time;
    },
    SetString: function (str, len)
    {
        if (typeof (str) == "undefined") return "";
        var strlen = 0;
        var s = "";
        for (var i = 0; i < str.length; i++)
        {
            if (str.charCodeAt(i) > 128) strlen += 2;
            else strlen++;
            s += str.charAt(i);
            if (strlen >= len) return s;
        }
        return s;
    },
    SH: function ()
    {
        var tim;
        $("#top_Nav #L .s").hover(function ()
        {
            $(this).siblings().find(".dbd").hide();
            $(this).find(".dbd").show();
            clearTimeout(tim);
        },
        function ()
        {
            tim = setTimeout(overDiv, 500);
            function overDiv()
            {
                $(this).find(".dbd").slideUp();
            }
        });
    },
    islogin: function ()
    {
        var t_time = this.localTime();
        var str = '';
        str += '<div class="row" id="topNav">';
        str += '<span class="welcome"><span class="time">' + t_time + '，</span><a class="user" target="_blank" href="http://home.pomoho.com/' + _space_user.username + '.shtml" title="' + _space_user.nick + '" >' + PUB.SetString(_space_user.nick, 10) + '</a></span>';
        str += '<span class="s"><a class="count" title="你的帐户" href="http://b.pomoho.com/manage/index.aspx" target="_blank" >帐户</a>';
        str += '   <div class="dbd s3">';
        str += '     <ul>';
        str += '       <li><a class="d_item" title="我的视频" href="http://b.pomoho.com/manage/managevideo.aspx" target="_blank" >我的视频</a></li>';
        str += '       <li><a class="d_item" title="我的订阅" href="http://b.pomoho.com/manage/subscribevblog.aspx" target="_blank" >我的订阅</a></li>';
        str += '       <li><a class="d_item" title="我的收藏" href="http://b.pomoho.com/manage/managevideo.aspx?type=favs" target="_blank" >我的收藏</a></li>';
        str += '       <li><a class="d_item" title="我的相册" href="http://b.pomoho.com/manage/managealbum.aspx" target="_blank" >我的相册</a></li>';
        str += '     </ul>';
        str += '     <div class="m1"><a title="更多管理" href="http://b.pomoho.com/manage/index.aspx" target="_blank" >更多..&nbsp;&nbsp;</a></div>';
        str += '   </div>';
        str += ' </span>';
        str += ' <a title="退出登录" href="http://b.pomoho.com/ui/logout.aspx?AfterLoginReturnURL=' + window.location + '" >退出</a>';
        str += '</div>';
        $("#L").removeClass().html(str);
        this.SH();
        // this.loadScript("http://notice.pomoho.com/loadmessage2.0.aspx?v=3");
    },
    closeDiv: function ()
    {
        if ($.browser.msie && String($('body').attr('id')) == 'B-Upload')
        {
            Pra.ui.overlay();
        } else if (String($('body').attr('id')) == 'B-Upload')
        {
            $("#zhezhao").remove();
        } else
        {
            $("#zhezhao").hide();
        }
        $("#Prompt").hide();
        return false;
    },
    login: function (sType, sTarget, sUrl, callback)
    {
        var userName = $.trim($("#uidName").val());
        var pwd = $("#uidPwd").val();
        if (userName == '' || pwd == '')
        {
            alert("用户名或者密码不能为空");
        } else
        {
            if (sType || sUrl)
            {
                PUB.ui.logDiagAjax(userName, pwd, sType, sTarget, sUrl, callback);
            } else
            {
                PUB.logAjax(userName, pwd, callback);
            }
        }
    },
    ui: function ()
    {
        return {
            logDiag: function (sType, sTarget, sUrl)
            {
                if (isLogin)
                {
                    if (sType == 'new')
                    {
                        window.open(sTarget);
                    } 
                    else
                    {
                        window.location.href = sTarget;
                    }
                } 
                else
                {
                    // PUB_v2.loginfo(sType, sTarget, sUrl);
                }
            },
            logDiagAjax: function (userName, pwd, sType, sTarget, sUrl)
            {
                $.ajax({
                    url: sUrl,
                    dataType: "xmlDocument",
                    type: "post",
                    data: "action=http://b.pomoho.com/ui/logindo.aspx&form_name=" + userName + "&form_password=" + pwd + "&type=gamelogin&random=" + Math.random(),
                    error: function ()
                    {
                        alert('可能网络问题,登录失败,请重试');
                    },
                    success: function (result)
                    {
                        var userlog = eval(result);
                        switch (parseInt(userlog[0].stat))
                        {
                            case -1: alert("登录帐号不存在");
                                break;
                            case -2: alert("用户名或者密码错误,请重试");
                                break;
                            case 1:
                                PUB.cookie('UserInfo', userlog[1].UserInfo, {
                                    path: '/',
                                    domain: '.pomoho.com',
                                    expires: 1 / 6
                                });
                                PUB.cookie('LoginInfo', userlog[2].LoginInfo, {
                                    path: '/',
                                    domain: '.pomoho.com',
                                    expires: 1 / 6
                                });
                                //PUB.init();
                                if (String($('body').attr('id')) == 'B-Upload-1' && (n == true) && (typeof (flag) == 'undefined' || flag == null))
                                {
                                    PUB.upload.unite('GoTo2');
                                    start_upload($('#file1').val(), $('#uploadForm_Title').val());
                                    return;
                                }
                                if (sType == 'local')
                                {
                                    window.location.href = sTarget;
                                } else if (sType == 'new')
                                {
                                    PUB.closeDiv();
                                    window.open(sTarget);
                                }
                                if (typeof (flag) == 'undefined' || flag == null) PUB.closeDiv();
                                break;
                            default:
                                alert("系统错误,请重试，错误代码：" + userlog[1].ErrMsg);
                        }
                    }
                });
            }
        }
    },
    pos: function ()
    {
        return {
            elementTop: function (element)
            {
                var y = 0;
                for (var e = element; e; e = e.offsetParent) y += e.offsetTop;
                for (e = element.parentNode; e && e != document.body; e = e.parentNode) if (e.scrollTop) y -= e.scrollTop;
                return y;
            }
        }
    } (),
    gettime: function ()
    {
        var time = new Date();
        var t_year = ($.browser.msie) ? time.getYear() : String(time).split(" ")[3];
        var t_time = ($.browser.msie) ? String(time).split(" ")[3].substr(0, 5) : String(time).split(" ")[4].substr(0, 5);
        var f_time = t_year + "-" + parseInt(time.getMonth() + 1) + "-" + time.getDate() + " " + t_time;
        return f_time;
    },
    logAjax: function (userName, pwd, callback)
    {
        var urlRoot = window.location.hostname;
        var urlString = window.location.toString().toLowerCase();
        var urlstr;
        if (urlString.indexOf("video.pomoho.com/") == -1)
        {
            urlstr = "/do/interfaces/sendajaxreq.aspx";
        } else
        {
            urlstr = "/sendajaxreq.aspx";
        }
        $.ajax({
            url: "http://" + urlRoot + urlstr,
            dataType: "xmlDocument",
            type: "post",
            data: "action=http://b.pomoho.com/ui/logindo.aspx&form_name=" + userName + "&form_password=" + pwd + "&type=gamelogin&random=" + Math.random(),
            error: function ()
            {
                alert('可能网络问题,登录失败,请重试!');
                PUB.closeDiv();
            },
            success: function (result)
            {
                var userlog = eval(result);
                switch (parseInt(userlog[0].stat))
                {
                    case -1: alert("登录帐号不存在");
                        break;
                    case -2: alert("用户名或者密码错误,请重试");
                        break;
                    case 1:
                        PUB.cookie('UserInfo', userlog[1].UserInfo, {
                            path: '/',
                            domain: '.pomoho.com',
                            expires: 1 / 6
                        });
                        PUB.cookie('LoginInfo', userlog[2].LoginInfo, {
                            path: '/',
                            domain: '.pomoho.com',
                            expires: 1 / 6
                        });
                        var urlString = window.location.toString().toLowerCase();
                        if (urlString.indexOf("pomoho.com/combo") != -1 && (typeof (flag) == 'undefined' || flag == null))
                        {
                            window.location.reload();
                            return
                        }
                        //PUB.init();
                        if (String($('body').attr('id')) == 'B-Upload' && document.getElementById("hid_n").value == "true" && (typeof (flag) == 'undefined' || flag == null))
                        {
                            document.getElementById("FrameUpload").contentWindow.PUB.upload.unite('GoTo2');
                            document.getElementById("FrameUpload").contentWindow.start_upload(document.getElementById("FrameUpload").contentWindow.$('#file1').val(), document.getElementById("FrameUpload").contentWindow.$('#uploadForm_Title').val());
                            if (document.getElementById("FrameUpload").contentWindow.$('#hid_ver').val() == 'family')
                            {
                                document.getElementById("FrameUpload").contentWindow.$('#Upload_2 .s4').addClass('none');
                                document.getElementById("FrameUpload").contentWindow.$('#Upload_2 .s5').addClass('none');
                                $('#Layout_1').height('650px');
                            } else
                            {
                                $('#Layout_1').height('700px');
                            }
                        }
                        if (typeof (flag) == 'undefined' || flag == null) PUB.closeDiv();
                        else if (flag == 1)
                        {
                            PUB.user.haveFriend();
                            flag = null;
                        } else if (flag == 2)
                        {
                            PUB.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=2&imdbid=" + flvid);
                            flag = null;
                            PUB.closeDiv();
                        } else if (flag == 3)
                        {
                            f_addfriend(_userid);
                            flag = null;
                            PUB.closeDiv();
                        } else if (flag == 4)
                        {
                            flag = null;
                            PUB.closeDiv();
                            f_comboInterFace(addPram.otype, addPram.atype, addPram.comboid, _space_user.uid);
                            PUB.closeDiv();
                        } else if (flag == 5)
                        {
                            flag = null;
                            PUB.ReUrl(pathUrl);
                            PUB.closeDiv();
                        } else if (flag == 6)
                        {
                            flag = null;
                            PUB.commentJudge();
                        }
                        if ('undefined' != typeof (callback))
                        {
                            callback();
                        }
                        break;
                    default:
                        alert("系统错误,请重试，错误代码：" + userlog[1].ErrMsg);
                        PUB.closeDiv();
                }
            }
        });
    },
    UserLogin: function (userName, password, success, error, complete, timeout)
    {
        var param = { userName: userName, password: password };
        var status = 0;  // 0-处理中 1-成功 2-出错
        $.ajax({
            type: "get",
            url: this.actionUrl,
            data: param,
            dataType: "jsonp",
            jsonp: "jsoncallback",
            timeout: timeout > 0 ? timeout : 10000,
            success: function (result)
            {
                if (status == 0) // 是否为处理中状态
                    status = 1;  // 1-成功
                else
                    return;


                success(result);
            },
            complete: function ()
            {
                if (status == 0)
                {
                    status = 2;
                    error();
                }

                complete();
            }
        });
    },
    submitF: function (e)
    {
        var event = window.event || e;
        if (event.keyCode == 13) $("#btnlog").click();
    },
    EXC: function (e)
    {
        var event = window.event || e;
        if (event.keyCode == 27) PUB.closeDiv();
    },
    cookie: function (name, value, options)
    {
        if (typeof (value) != 'undefined')
        {
            options = options || {};
            if (value === null)
            {
                value = '';
                options.expires = -1;
            }
            var expires = '';
            if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString))
            {
                var date;
                if (typeof options.expires == 'number')
                {
                    date = new Date();
                    date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
                } else
                {
                    date = options.expires;
                }
                expires = '; expires=' + date.toUTCString();
            }
            var path = options.path ? '; path=' + options.path : '';
            var domain = options.domain ? '; domain=' + options.domain : '';
            var secure = options.secure ? '; secure' : '';
            document.cookie = [name, '=', name + '=' + value, expires, path, domain, secure].join('');
        } else
        {
            var cookieValue = null;
            if (document.cookie && document.cookie != '')
            {
                var cookies = document.cookie.split(';');
                for (var i = 0; i < cookies.length; i++)
                {
                    var cookie = jQuery.trim(cookies[i]);
                    if (cookie.substring(0, name.length + 1) == (name + '='))
                    {
                        cookieValue = unescape(cookie.substring(name.length + 1));
                        break;
                    }
                }
            }
            return cookieValue;
        }
    },
    collect: function ()
    {
        PUB.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=2&imdbid=" + flvid);
    },
    GetValidCodeImg: function ()
    {
        ValidCodeURL = baseurl + "/video/ValidCode.aspx?type=1";
        document.getElementById('Comment') ? document.getElementById("validcode").src = ValidCodeURL + "&objid=" + flvid + "&ran=" + Math.random() : document.getElementById("validcode").src = ValidCodeURL + "&objid=" + _space_user.uid + "&ran=" + Math.random();
    },
    CodeImgLoader: function ()
    {
        var s = '<a href="javascript:PUB.GetValidCodeImg();" title="看不清楚？请点击刷新验证码！" style="position:relative;top:6px;*top:4px;" ><img id="validcode" border=0  width="60" height="20" src="" /></a>';
        $('#tb_validcode').after(s).removeAttr('onfocus');
        $('#post_content').unbind('focus');
        $('#post_content').click(function ()
        {
            if ($("#QuickComment").length > 0)
            {
                $(".f_v").hide();
                $("#QuickComment").hide();
            }
        });
        this.GetValidCodeImg();
    },
    hideComment: function (num)
    {
        if (String(window.location).match(/http:\/\/home.*/))
        {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        } else
        {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        }
        $('#Comment h3 span.count').html(20);
    },
    commentQuote: function (bid)
    {
        var re_q_txt = document.getElementById("re_q_" + bid).value;
        document.getElementById("post_content").value = "[quote]" + re_q_txt + "[/quote]";
        $('#Comment textarea').focus();
    },
    SetValidCodeImg: function (what)
    {
        var ValidCodeHtml = '';
        ValidCodeHtml = '请输入验证码&nbsp;&nbsp;<input id="tb_validcode" type="text" onfocus="javascript:PUB.CodeImgLoader();" style="width:60px; border:1px #7B9EBD solid;margin:0 5px 0 0;" />';
        var s = $(what + ' .commentAdd .form .submit').html();
        $(what + ' .commentAdd .form .submit').html(ValidCodeHtml + s);
    },
    SendCallBack: function (v, sv)
    {
        alert('ffffffffffffdddddddddddddsssssssssss');
        if (v == 0)
        {
            alert("您的验证码错误！");
        }
        if (v == -1)
        {
            alert("您的验证码已失效。请点击验证码图片，重新获取验证码！");
        }
        setTimeout("$('#Comment .mDocument').eq(0).remove();", 1000);
        if ($('#Comment .cl').length > 1)
        {
            $('#Comment .cl').eq(0).remove();
            $('#Comment h3').eq(0).remove();
        }
        setTimeout("textarea.attr('value', '" + sv + "').focus();", 1000);
        setTimeout(function ()
        {
            var icount = $('#CM h3 .title span').text() ? $('#CM h3 .title span').text() : 0;
            icount = parseInt(icount);
            var vtitle = $.trim($('title').html());
            var s_href = 'http://video.pomoho.com/review.aspx?flvid=' + flvid + '&icount=' + (icount - 1) + '&title=' + vtitle + '&uid=' + _space_user.uid;
            $('#Comment h3 .title span').text(icount - 1).parents('h3').find('.more a').attr('href', s_href);
        },
        1500);
    },
    commentReplyFill: function ()
    {
        var c = textarea.val().replace(/\[em(\d+)\]/g, "<img src='http://static.pomoho.com/images/em/em$1.gif' />");
        var u = isLogin ? '<a href="javascript:;">' + _space_user.spacename + '</a>' : '游客';
        var s = '';
        var mdL = $('#Comment .cl').length;
        var icount = $('#CM h3 .title span').text() ? $('#CM h3 .title span').text() : 0;
        icount = parseInt(icount);
        var vtitle = $.trim($('title').html());
        var s_href = 'http://video.pomoho.com/review.aspx?flvid=' + flvid + '&icount=' + (icount + 1) + '&title=' + vtitle + '&uid=' + _space_user.uid;
        if (mdL)
        {
            s += '<div class="mDocument" style="_width:100%;">';
            s += ' <div class="photo"><img src="http://static.pomoho.com/static/images/photo_68.gif" alt="" /></div>';
            s += ' <div class="detail">';
            s += '  <span class="n_user">' + u + '</span>';
            s += '  <p class="text">' + c + '</p>';
            s += ' </div>';
            s += ' <div class="handle">';
            s += '  <span class="t_release">' + PUB.gettime() + '</span>';
            s += ' </div>';
            s += '</div>';
            $('#Comment .cl').prepend(s).fadeTo('slow', 1);
            $('#CM h3 .title span').text(icount + 1).parents('h3').find('.more a').attr('href', s_href);
        } else
        {
            s += '<h3><span class="title">网友评论（共<span>' + (icount + 1) + '</span>条）</span><span class="more"><a target="_blank" href="' + s_href + '">更多</a></span></h3>';
            s += '<div class="cl showblock"><div class="mDocument">';
            s += ' <div class="photo"><img src="http://static.pomoho.com/static/images/photo_68.gif" alt="" /></div>';
            s += ' <div class="detail">';
            s += '  <span class="n_user">' + u + '</span>';
            s += '  <p class="text">' + c + '</p>';
            s += ' </div>';
            s += ' <div class="handle">';
            s += '  <span class="t_release">' + PUB.gettime() + '</span>';
            s += ' </div>';
            s += '</div></div>';
            $('#span_video_review').prepend(s).fadeTo('slow', 1);
        }
        textarea.attr('value', '').focus();
    },
    doingReply: function ()
    {
        var timer_doing = null;
        $('#Doing input[type=submit]').click(function ()
        {
            var content = $.trim($('#Doing textarea').val());
            if (content == null)
            {
                alert('记事内容不可为空！');
                $('#Doing textarea').focus();
                return;
            }
            if (timer_doing != null)
            {
                var d = new Date();
                if ((Date.parse(d.toUTCString()) - 60000) < timer_doing)
                {
                    alert('留言间隔不得少于1分钟！');
                    $('#Doing textarea').focus();
                    return;
                }
            } else
            {
                var d = new Date();
                timer_doing = Date.parse(d.toUTCString());
            }
            var ct = PUB.pos.elementTop($('#Doing')[0]);
            window.scrollTo(0, ct - 30);
            this.blur();
            setTimeout("PUB.doingReplyFill()", 1000);
            var content = escape(content.replace(/</g, '&lt;').replace(/>/g, '&gt;').replace('\'', '‘'));
            PUB.loadScript(baseurl + "/space/mydoingajax.aspx?opreatetype=add&writecontent=" + content + "&userid=" + _space_user.uid, {
                random: false
            });
            return false;
        });
    },
    doingReplyFill: function ()
    {
        var c = $.trim($('#Doing textarea').val());
        var s = '<li><div>' + c + '</div><p>书写于<span>现在</span><a href="javascript:;" onclick="$(this).parent().parent().hide()" class="is_login" title="删除">删</a></p></li>';
        if (!$('#Doing .nl')[0])
        {
            $('#Doing h2').after('<div class="nl detail"></div>');
        }
        $(s).prependTo('#Doing .nl');
        $('#Doing textarea').attr('value', '').focus();
    },
    commentLoad: function ()
    {
        // $('<div class="loading">评论加载中...</div>').insertBefore($('.commentAdd'));
        var sh = ("innerHeight" in window) ? window.innerHeight : document.documentElement.offsetHeight;
        var comm = $('#Comment')[0];
        var commentTop = comm.offsetTop + 100;
        setTimeout(function ()
        {
            var reviewNum = parseInt($('#video_' + flvid + '_999').find('.c_review span').html());
            if (commentTop < sh && reviewNum > 0)
            {
                PUB.ajaxLoad('GET', 'http://home.pomoho.com/do/interfaces/getvideoreview.aspx', 'videoid=' + flvid + '&r=' + Math.random(), 'html', '',
		        function ()
		        {
		            $('#Comment').prepend(_getDATA);
		        }
	        );
            } else if (commentTop >= sh && reviewNum > 0)
            {
                (function g()
                {
                    if (document.documentElement.scrollTop + sh >= commentTop)
                    {
                        PUB.ajaxLoad('GET', 'http://home.pomoho.com/do/interfaces/getvideoreview.aspx', 'videoid=' + flvid + '&r=' + Math.random(), 'html', '',
			        function ()
			        {
			            $('#Comment').prepend(_getDATA);
			        }
		         );
                    } else { setTimeout(function () { g(); }, 2000); }
                })();
            }
        }, 5000);
    },
    commentReply: function (what)
    {
        this.SetValidCodeImg(what);
        var _self = this;
        $('#post_content').bind('focus',
        function ()
        {
            _self.CodeImgLoader()
        });
        $(what + ' input[type=submit]').click(function ()
        {
            textarea = $(what + ' textarea');
            if ($.trim(textarea.val()) == '')
            {
                alert('留言内容不可为空！');
                textarea.focus();
                return;
            }
            var sValidCode = "";
            if (document.getElementById("tb_validcode") != null)
            {
                sValidCode = document.getElementById("tb_validcode").value;
                if ($.trim(sValidCode) == '')
                {
                    alert('验证码不可为空！');
                    return;
                }
            }
            var content = textarea.val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@-->");
            switch (what)
            {
                case '#Comment':
                    PUB.loadScript(baseurl + "/video/dealajaxdata.aspx?itype=1&imdbid=" + flvid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                        random: true
                    });
                    break;
                case '#GuestBook':
                    PUB.loadScript(baseurl + "/space/personjs.aspx?dotype=4&userid=" + _space_user.uid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                        random: true
                    });
            }
            var ct = PUB.pos.elementTop(document.getElementById(what.slice(1)));
            window.scrollTo(0, ct - 30);
            this.blur();
            setTimeout("PUB.commentReplyFill()", 1000);
            _self.GetValidCodeImg();
            return false;
        });
    },
    commentJudge: function ()
    {
        var sValidCode = document.getElementById("tb_validcode").value;
        if (document.getElementById('Comment'))
        {
            var content = $('#Comment textarea').val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@-->");
            PUB.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=1&imdbid=" + flvid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                random: true
            });
        } else if (document.getElementById('GuestBook'))
        {
            var content = $('#GuestBook textarea').val().replace("<", "&lt;").replace(">", "&gt;").replace("&", "<--@@-@@-->");
            PUB.loadScript(baseurl + "/space/personjs.aspx?dotype=4&userid=" + _space_user.uid + "&content=" + escape(content) + "&validcode=" + sValidCode, {
                random: true
            })
        }
        setTimeout("PUB.commentReplyFill()", 1000);
        PUB.GetValidCodeImg();
        PUB.closeDiv();
    },
    emotion: function (what)
    {
        var emotionID = 1;
        $(what + ' .emotion').find('.l').click(function ()
        {
            if (emotionID >= 2)
            {
                $('#emotionBox').animate({
                    left: -(450 * (emotionID - 2))
                },
                1000);
                if (emotionID == 2)
                {
                    $(what + ' .l').removeClass('l_b').attr('title', '左边没有了');
                } else if (emotionID == 4)
                {
                    $(what + ' .r').addClass('r_b').attr('title', '向右翻');
                }
                emotionID--;
            }
            this.blur();
            return false;
        }).end().find('.r').click(function ()
        {
            if (emotionID <= 3)
            {
                $('#emotionBox').animate({
                    left: -(450 * emotionID)
                },
                1000);
                if (emotionID == 1)
                {
                    $(what + ' .l').addClass('l_b').attr('title', '向左翻');
                } else if (emotionID == 3)
                {
                    $(what + ' .r').removeClass('r_b').attr('title', '右边没有了');
                }
                emotionID++;
            }
            this.blur();
            return false;
        }).end().find('div a').each(function ()
        {
            $(this).click(function ()
            {
                var tmp = $(what + ' textarea').val() + $(this).find('img').attr('src').replace(/.+\/(em\d+)\.gif/g, '[$1]');
                $(what + ' textarea').val(tmp);
                return false;
            });
        });
    },
    emotionWR: function (what)
    {
        var s = '';
        s += '<div style="position:relative;width:450px;height:60px;overflow:hidden;margin:5px auto;"><div id="emotionBox" style="position:absolute;left:0;top:0;width:1800px;">';
        var l = 'http://static.pomoho.com/images/em/';
        var alt = ['黑星打', '大', '泡', '蹦', '继续', '狂', '黑星殴', '吹', '捅', '被殴', '飞', '嘘', '赖', '顶', '变', '滚球', '生', '膜拜', '转', '口', 'KI', '鬼', '抓狂', '扯', '流', '闭嘴', 'HI', '可爱', '摇', '躲', '多', '吉'];
        for (var i = 1; i <= 4; i++)
        {
            s += '<div style="width:450px;float:left;text-align:center;">';
            for (var j = (i - 1) * 8 + 1; j <= i * 8; j++)
            {
                if (j <= 32)
                {
                    s += '<a href="" title="' + alt[j - 1] + '" style="margin:0 1px;"><img src="' + l + 'em' + j + '.gif" height="50" width="50" /></a>';
                }
            }
            s += '</div>';
        }
        s += '</div></div>';
        s += '<a href="" class="l" title="左边没有了">向左翻</a><a href="" class="r r_b" title="向右翻">向右翻</a>';
        $(s).appendTo($('.emotion'));
        this.emotion(what);
        this.commentLoad();
    }
}
function SendCallBack(v, sv) {
    PUB.SendCallBack.call(this, v, sv);
}
Pui={};
Pui.space = {
    init: function() {
		this.gotoLink();
    },
	share: function(link, title, content) {
        var itieba_share = 'http://tieba.baidu.com/i/sys/share?link=' + link + '&type=video&title=' + title + '&content=' + content;
        if (!window.open(itieba_share, 'itieba', 'toolbar=0,resizable=1,scrollbars=yes,status=1,width=626,height=436')) {
            location.href = itieba_share;
        }
    },
    collect: function() {
        Pui.loadScript("http://www.pomoho.com/do/video/dealajaxdata.aspx?itype=2&imdbid=" + flvid);
    },
    gotoLink: function() {
        var vTitle = encodeURIComponent($('title').html().replace(/(^\s*)|(\s*$)/g, ""));
        var vLink = encodeURIComponent('http://home.pomoho.com/' + _space_user.username + '/' + flvid);
        var vContent = encodeURIComponent('http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid);
        var vContentTieba = encodeURIComponent('http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid+'&qudao=tieba');
		var vBogo = encodeURIComponent('http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid+'&outall=true&qudao=51com');
        var vSource = encodeURIComponent('爆米花网');
        var vSourceUrl = encodeURIComponent('http://www.pomoho.com/');
        var s = '<span class="icos"><a id="wuyicom" href="http://diary.51.com/mod/diary_video_interface.php?vaddr=' + vBogo+ '&title=' + vTitle + '&charset=utf-8" target="_blank" title="51交友社区">转贴至51交友社区</a><a id="QQ" href="http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + vLink+ '&title=' + vTitle + '&charset=utf-8" target="_blank" title="QQ空间">转贴至QQ空间</a><a id="renren" href="http://share.renren.com/share/buttonshare.do?link=' + vLink + '&title=' + vTitle + '" target="_blank" title="转贴至人人网">转贴至人人网</a><a id="kaixin" href="http://www.kaixin001.com/repaste/share.php?rurl=' + vLink + '&rcontent=' + vLink + '&rtitle=' + vTitle + '" target="_blank" title="转贴至开心网">转贴至开心网</a><a id="sina" href="http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_pomoho_weibo&url=' + vLink + '&title=' + vTitle + '&source=' + vSource + '&sourceUrl=' + vSourceUrl + '&appkey=1854178289&pic='+pic+'" target="_blank" title="转贴至新浪微博">转贴至新浪微博</a><a id="itieba" href="" onclick="Pui.space.video.share(\'' + vLink + '\',\'' + vTitle + '\',\'' + vContentTieba + '\');return false;" title="转贴至i贴吧">转贴至i贴吧</a></span><span class="GdIcos"><a id="feixin" href="http://space.fetion.com.cn/api/share?source='+vSource+'&url='+vLink+'&title='+vTitle+'" target="_blank" title="转发至飞信空间">转发至飞信空间</a></span>';
        $(s).appendTo('.video_info .handle');
        this.zz();
    },
    zz: function(mv) {
        var urlParm = "";
        var htmlcode = '';
        var vTitle = encodeURIComponent($('title').html().replace(/(^\s*)|(\s*$)/g, ""));
        var vLink ='http://home.pomoho.com/' + _space_user.username + '/' + flvid;
        var vContent = 'http://video.pomoho.com/swf/out_player.swf?flvid=' + flvid+"&outall=true";
        var vSource = encodeURIComponent('爆米花网');
        var vSourceUrl = encodeURIComponent('http://www.pomoho.com/');
        var s = '';
        s += '<div id="ZZ" style="display:none;">';
        s += ' <div class="s1">';
        urlParm = "flvid";
        htmlcode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="480" height="396" id="object"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="true" /><param name="movie" value="'+vContent+'" /><embed src="'+vContent+'" quality="high" width="480" height="396" allowScriptAccess="always"/></object>';
        if (String(window.location).match(/http:\/\/video\.dvod.*/)) {
            s += '  此节目地址（URL）<br /><input type="text" class="url" value="http://video.dvod.com.cn/news/' + flvid + '.shtml" /><br />';
        } else {
            s += '  此节目地址（URL）<br /><input type="text" class="url" value="'+vLink+'" /><br />';
        }
        s += '  把播放器显示到个人空间或Blog<br /><input type="text" class="url" value="'+vContent+'" /><br />';
        s += '  HTML代码,适用于个人空间（或其他类型的Blog）<br /><input type="text" class="url" value="" /><br />';
        s += '  BBS代码<br /><input type="text" class="url" value="[flash]'+vContent+'[/flash]" />';
        s += ' </div>';
        s += '  <p><a href="" onclick="$(\'#ZZ\').slideUp();return false;">关闭</a></p>';
        s += '</div>';
        var vPath = '#VideoPlayer #Handle';
        $(s).appendTo($('#Space')).css({
            'z-index': '9999',
            'top': '552px',
            'left': '16px'
        });
        $(vPath).find('.s4').click(function() {
            $('#ZZ').slideToggle('slow');
            this.blur();
            return false;
        });
        $('#ZZ .url').eq(2).attr('value', htmlcode).end().hover(function() {
            $(this).select();
        },
        function() {
            $(this).blur();
        });
    },
    hideComment: function(num) {
        if (String(window.location).match(/http:\/\/home.*/)) {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        } else {
            $('#Comment .mDocument').filter(':gt(19)').hide();
        }
        $('#Comment h3 span.count').html(20);
    }
}
Pui.LazyLoad={
    lazyloadThis:null,
    //初始化程序
    _initialize:function(elem)
    {
        lazyloadThis=Pui.LazyLoad;
        lazyloadThis._timer=null;//定时器
        lazyloadThis.isFinish=false;//是否完成
        lazyloadThis._lock=false,//锁住
        lazyloadThis.delay=1000;//定时间隔
        lazyloadThis.windowObj=lazyloadThis.getWindowRect();
        lazyloadThis.scrollObj=lazyloadThis.getScroll();
        lazyloadThis.containerObj=lazyloadThis.getRect(elem);
    },
    load:function(run)
    {
        if(run==null||typeof(run) != "function") return;
        $(window).scroll(function()
        {
            lazyloadThis.scrollObj=lazyloadThis.getScroll();
            if((lazyloadThis.scrollObj.top+lazyloadThis.windowObj.bottom)>lazyloadThis.containerObj.top)
            {
                lazyloadThis._delay(run);
                lazyloadThis.isFinish=true;
            } 
            return false;
        });
        $(window).scroll();
    },
    getScroll:function()
    {
        var t, l, w, h;
        if (document.documentElement && document.documentElement.scrollTop) 
        {
            t = document.documentElement.scrollTop;
            l = document.documentElement.scrollLeft;
            w = document.documentElement.scrollWidth;
            h = document.documentElement.scrollHeight;
        } 
        else if (document.body) 
        {
            t = document.body.scrollTop;
            l = document.body.scrollLeft;
            w = document.body.scrollWidth;
            h = document.body.scrollHeight;
        }
        return { "top": t, "left": l, "right": w, "bottom": h };
    }, 
    getWindowRect:function()
    {
        return ( "innerHeight" in window )?{"left":	0, "right":	window.innerWidth,"top":0, "bottom":window.innerHeight}:{"left":	0, "right":	document.documentElement.offsetWidth,"top":0, "bottom":document.documentElement.offsetHeight};
    },
    getRect:function(node) {
        var n = node, left = 0, top = 0;
        while (n) { left += n.offsetLeft; top += n.offsetTop; n = n.offsetParent; };
        return {
            "left": left, "right": left + node.offsetWidth,
            "top": top, "bottom": top + node.offsetHeight
        };
      },
    //延时程序
    _delay:function(run) {
        clearTimeout(lazyloadThis._timer);
        if ( lazyloadThis.isFinish ) return;
        var oThis = this, delay = lazyloadThis.delay;
        if ( lazyloadThis._lock ) {//防止连续触发
            lazyloadThis._timer = setTimeout( function(){ oThis._delay(run); }, delay );
        } else {
            lazyloadThis._lock = true; run();lazyloadThis.testAlert("runed");
            setTimeout( function(){ oThis._lock = false; }, delay );
        }
    },
    testAlert:function(str)
    {
        if(location.href.indexOf("localhost")>-1)
        {
            alert(str);   
        }
    }
};
Pui.showData = function(json) {
    var path = {
        user: ['.t_login span', '.c_friend span', '.c_fans span', '.c_view span', '.c_video span', '.c_flower span'],
        video: ['.c_view span', '.c_review span', '.c_bookmark span'],
        special: ['.c_video span', '.c_view span', '.c_rss span', '.t_update span', '.t_length span'],
        combo: ['.d_video span', '.d_collect span', '.d_topic span', '.d_menber span', '.d_album span', '.d_mvvideo span'],
        combo_handle: ['.c_num', '.c_num_m']
    };
    var path_n = {
        user: ['.d_time_login span', '.d_friend span', '.d_fans span', '.d_view span', '.d_video span', '.d_flower span'],
        video: ['.d_view span', '.d_review span', '.d_bookmark span'],
        special: ['.d_video span', '.d_view span', '.d_rss span', '.d_update span', '.d_length span'],
        combo: ['.d_video span', '.d_collect span', '.d_topic span', '.d_menber span', '.d_album span', '.d_mvvideo span']
    };
    $('.t_login').html('最近登录：<span></span>');
    for (var i = 0,
    length = json.length; i < length; i++) {
        var type = json[i].type,
        id = json[i].id,
        data = json[i].data,
        wrap = '#' + type + '_' + id;
        if (!$(wrap)[0]) continue;
        for (j = 0; j < path[type].length; j++) {
            if ($(wrap + ' ' + path[type][j])[0]) {
                $(wrap + ' ' + path[type][j])[0].innerHTML = data[j];
            } else if ($(wrap + ' ' + path_n[type][j])[0]) {
                $(wrap + ' ' + path_n[type][j])[0].innerHTML = data[j];
            }
        }
    }
};
Pui.video = {
    channelID: -1,
    strTime: "24hour",
    videoTitle: document.title,
    init: function ()
    {
        if (typeof (channelId) != 'undefined')
        {
            Pui.video.channelID = channelId;
        }
        if (typeof (strTime) != 'undefined')
        {
            Pui.video.strTime = strTime;
        }
        if (typeof (videoTitle) != 'undefined')
        {
            Pui.video.videoTitle = videoTitle;
        }
        Pui.video.hotVideo();
        Pui.video.userVideoList();
        Pui.video.wideScreenAD();
        //Pui.video.relateVideo();
        Pui.video.relateKeyCallback();
    },
    quote: function (bid)
    {
        Pui.space.commentQuote.call(this, bid);
    },
    collect: function ()
    {
        PUB.collect.call(this);
    },
    hotVideo: function ()
    {
        var videoList = function (json)
        {
            var jsonlen = json.length;
            if (jsonlen > 9)
            {
                hotVideoPlay(json.slice(0, 9));
                hotVideoSearch(json.slice(9));
            }
            else
            {
                hotVideoSearch(json);
            }
        };
        var hotVideoSearch = function (arrJson)
        {
            $("<div>")
                    .attr({ id: "div_recommend" })
                    .insertAfter($("#div_relatedSearch"));

            var strLiList = '';
            for (var i = 0; i < arrJson.length; i++)
            {
                strLiList += "<li>";
                strLiList += "<a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + encodeURIComponent(arrJson[i].videoName) + "&_f=P0S05&vid=" + arrJson[i].videoID + "\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\"><img alt=\"" + arrJson[i].videoName + "\" src=\"" + arrJson[i].imgURL + "\"></a>";
                strLiList += "<p><a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + encodeURIComponent(arrJson[i].videoName) + "&_f=P0S05&vid=" + arrJson[i].videoID + "\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\">" + arrJson[i].videoName + "</a></p>";
                strLiList += "</li>";
            }
            var recommendBox = "<div class=\"videolist Recommend\">";
            recommendBox += "<div class=\"bt_title\"><h2>推荐视频</h2></div>";
            recommendBox += "<div class=\"showblock\">";
            recommendBox += "<ul>";
            recommendBox += strLiList;
            recommendBox += "</ul>";
            recommendBox += "</div>";
            recommendBox += "</div>";
            $("#div_recommend").html(recommendBox);
        };
        var hotVideoPlay = function (arrJson)
        {
            var more = arrJson[0].channelText || (typeof (channelEngName) == 'undefined' ? "" : channelEngName) || "mm";
            var strList = "<div class=\"Popular\" style=\"display:none\">";
            strList += "<div class=\"bt_title\"><a target=\"_blank\" href=\"http://www.pomoho.com/" + more + "/" + more + ",video,week,1\">更多</a><h2>热门视频</h2></div>";
            strList += "<div class=\"showblock\">";

            var strPage = '';
            var iPage = 1;
            for (var i = 0; i < arrJson.length; i++)
            {
                if (i % 3 == 0)
                {
                    strList += "<ul class=\"" + (i == 0 ? "cover" : "hide cover") + "\">";
                }

                strList += "<li>";
                strList += "<a href=\"" + arrJson[i].spaceURL + "/" + arrJson[i].videoID + "?P0P08\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\"><img alt=\"" + arrJson[i].videoName + "\" src=\"" + arrJson[i].imgURL + "\"></a>";
                strList += "<p><a href=\"" + arrJson[i].spaceURL + "/" + arrJson[i].videoID + "?P0P08\" title=\"" + arrJson[i].videoName + "\" target=\"_blank\">" + arrJson[i].videoName + "</a></p>";
                strList += "</li>";

                if ((i + 1) % 3 == 0 || i == arrJson.length - 1)
                {
                    strList += "</ul>";
                    strPage += "<li " + (strPage == '' ? "class=\"ac\"" : "") + ">" + (iPage++) + "</li>";
                }
            }
            strList += "<div class=\"page\">";
            strList += "<ol>" + strPage + "</ol>";
            strList += "</div>";
            strList += "</div>";
            strList += "</div>";
            if ($("#ByRight .Popular").length > 0)
            {
                $("#ByRight .Popular").remove();
            }
            $("#ByRight").prepend(strList);
            $("#ByRight .Popular").slideDown(2500);
            focusTurn();
        };
        if (typeof (hotVideoJson) == "undefined" || !(hotVideoJson instanceof Array))
        {
            return;
        }
        videoList(hotVideoJson);
    },
    userVideoList: function ()
    {
        var arrVideo = [
        "【笑掉大牙】老人【杰克逊模仿秀】|http://static.pomoho.com/pics/1_1_3963004498529.jpg|%e8%80%81%e4%ba%ba%e6%9d%b0%e5%85%8b%e9%80%8a%e6%a8%a1%e4%bb%bf%e7%a7%80|6303742",
        "当男医生遇到漂亮女病人|http://static.pomoho.com/pics/1_1_3963657717064.jpg|%e6%bc%82%e4%ba%ae%e5%a5%b3%e7%97%85%e4%ba%ba|6698819",
        "三个女人的震奶舞|http://static.pomoho.com/pics/1_1_3963873946304.jpg|%e9%9c%87%e5%a5%b6%e8%88%9e|6266029",
        "美女裸奔为环保性感雷人|http://static.pomoho.com/pics/1_1_3964381866289.jpg|%e7%be%8e%e5%a5%b3%e8%a3%b8%e5%a5%94%e4%b8%ba%e7%8e%af%e4%bf%9d%e6%80%a7%e6%84%9f%e9%9b%b7%e4%ba%ba|6658860",
        "日本萌系宅女瘦瘦操|http://static.pomoho.com/pics/1_1_3964627155239.jpg|%e6%97%a5%e6%9c%ac%e8%90%8c%e7%b3%bb%e5%ae%85%e5%a5%b3%e7%98%a6%e7%98%a6%e6%93%8d|6701999",
        "石光近00后教室热吻门|http://static.pomoho.com/pics/1_1_3964850258819.jpg|%e6%95%99%e5%ae%a4%e7%83%ad%e5%90%bb%e9%97%a8|5443613",
        "史上最雷人报警电话|http://static.pomoho.com/pics/1_1_3965105859279.jpg|%e9%9b%b7%e4%ba%ba|6163592",
        "最性感女教师朱松花|http://static.pomoho.com/pics/1_1_3966344959064.jpg|%e6%9c%80%e6%80%a7%e6%84%9f|6360412",
        "印度夜店震惊全世界|http://static.pomoho.com/pics/1_1_3966517442504.jpg|%e5%8d%b0%e5%ba%a6%e5%a4%9c%e5%ba%97|6608832",
        "哈利波特与死亡圣器预告|http://pic02.pomoho.com/grab_photo/201009/5899673.jpg|%e5%93%88%e5%88%a9%e6%b3%a2%e7%89%b9%e4%b8%8e%e6%ad%bb%e4%ba%a1%e5%9c%a3%e5%99%a8%e9%a2%84%e5%91%8a|5899673"
        ];
        var struserVideoList = "<div class=\"videolist\" id=\"Trundle\">";
        //struserVideoList+="<div class=\"bt_title\"><h2>该播客的视频列表</h2></div>";
        struserVideoList += "<div class=\"showblock\">";
        struserVideoList += "<div class=\"demo\">";
        var videoname = "";
        var videoimg = "";
        var enname = "";
        var vid = "";
        var arrtemp = [];
        var displayNum = Math.floor(Math.random() * (arrVideo.length - 2));
        struserVideoList += "<ul class=\"row\">";
        for (var i = 0; i < 3; i++)
        {
            arrtemp = arrVideo[displayNum++].split('|');
            if (arrtemp.length < 4)
            {
                return;
            }
            videoname = arrtemp[0];
            videoimg = arrtemp[1];
            enname = arrtemp[2];
            vid = arrtemp[3];
            struserVideoList += "<li>";
            struserVideoList += "<a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + enname + "&vid=" + vid + "&_f=P0S06\" title=\"" + videoname + "\" target=\"_blank\"><img alt=\"" + videoname + "\" src=\"" + videoimg + "\"></a>";
            struserVideoList += "<p><a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + enname + "&vid=" + vid + "&_f=P0S06\" title=\"" + videoname + "\" target=\"_blank\">" + videoname + "</a></p>";
            struserVideoList += "</li>";
        }
        struserVideoList += "</ul>";
        struserVideoList += "</div>";
        struserVideoList += "</div>";
        struserVideoList += "</div>";
        $("#Bar .videolist").eq(0).before(struserVideoList);
    },
    wideScreenAD: function ()
    {
        var sw = screen.width;
        if (typeof (sw) != 'undefined' && sw >= 1280)
        {
            var videoList = function (data)
            {
                var n = data.length, ul = document.createElement('ul');
                for (var i = 0; i < n; i++)
                {
                    var li = $('<li><a target="_blank" title="' + data[i].videoName + '" href="' + data[i].spaceURL + "/" + data[i].videoID + '?P0P09"><img src="' + data[i].imgURL + '" alt="' + data[i].videoName + '" /></a><p><a target="_blank" title="' + data[i].videoName + '" href="' + data[i].spaceURL + "/" + data[i].videoID + '?P0P09">' + data[i].videoName + '</a></p></li>');
                    $(ul).append(li);
                }
                $('#Space #ByRight').css({ 'float': 'left', 'margin': '0 15px' });
                $('#Space').width(1190).append($('<div class="videolist" style="width:190px;float:left;margin-top:0px;">').append('<div class="bt_title"><h2>昨日排行</h2></div>').append($('<div class="showblock" style="width:190px;"></div>').append(ul)));
            };
            if (typeof (hotVideoTopJson) == "undefined" || !(hotVideoTopJson instanceof Array))
            {
                return;
            }
            videoList(hotVideoTopJson);
        }
    },
    relateVideo: function ()
    {
        var shwovideolist = function (list, title)
        {
            if (typeof (list) == "object" && !(list instanceof Array))
            {
                if (list.videoList instanceof Array)
                {
                    list = list.videoList;
                }
                else
                {
                    list = [];
                }
            }
            if (list.length == 0) return "";
            var fristKeywords = title || list[0].videoName;
            var fristKeywordstitle = decodeURIComponent(fristKeywords);
            var str = "<div class=\"videolist\">";
            str += "<div class=\"bt_title\"><a target=\"_blank\" href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + fristKeywords + "&_f=POSO3\">更多</a><h2>相关视频</h2></div>";
            str += "<div class=\"showblock\">";
            str += "<ul>";
            var tmpStatSource = "P0P07";
            var temp = ',' + fristKeywordstitle + ',';
            var num = 9;
            for (var i = 0; i < list.length && 0 < num; i++)
            {
                if (temp.indexOf(list[i].videoName) > -1)
                {
                    continue;
                }
                num--;
                temp += list[i].videoName + ",";
                str += "<li>";
                str += "<a href=\"http://home.pomoho.com/" + list[i].spaceURL + "/" + list[i].videoID + "?" + tmpStatSource + "\" target=\"_blank\" title=\"" + list[i].videoName + "\"><img src=\"" + list[i].imgURL + "\" alt=\"" + list[i].videoName + "\"/></a>";
                str += "<p><a href=\"http://home.pomoho.com/" + list[i].spaceURL + "/" + list[i].videoID + "?" + tmpStatSource + "\" target=\"_blank\" title=\"" + list[i].videoName + "\">" + list[i].videoName + "</a></p>";
                str += "</li>";
            }
            str += "</ul>";
            str += "</div>";
            str += "</div>";
            if (temp != (',' + fristKeywordstitle + ','))
            {
                $("#relateVideo").append(str);
            }
        }
        var jsonFun = function ()
        {
            if ($("#relateVideo").length > 0)
            {
                var videoID = typeof (flvid) == "undefined" ? 5610450 : flvid;
                var _title = videoTitle;
                $.getJSON("http://search.pomoho.com/getrelatvevideojson.aspx?jsoncallback=?", { count: 10, videoid: videoID, title: _title }, function (json)
                {
                    if (json != null)
                    {
                        shwovideolist(json, _title);
                    }
                });
            }
        }
        setTimeout(function () { jsonFun(); }, 6000);
    },
    relateKeyCallback: function ()
    {
        if (typeof (arrRelateKey) == "undefined" || !(arrRelateKey instanceof Array))
        {
            return;
        }
        var json = arrRelateKey
        $("#div_relatedSearch").hide();
        var html = "<h3><span class=\"title\">相关搜索</span></h3><div class=\"showblock\"><ul>";
        var i = 1;
        $(json).each(function (j)
        {
            if ($(this)[0])
            {
                if (j < 4)
                {
                    var link = "<a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + $(this)[0].enkeyName + "&_f=P0S02\">" + decodeURIComponent($(this)[0].enkeyName) + "</a>&nbsp;";
                    $(".v_tag").html($(".v_tag").html() + link);
                }
                if ($(this)[0].data != "" && $(this)[0].data != null)
                {
                    $($(this)[0].data).each(function ()
                    {
                        html += "<li><a href=\"http://search.pomoho.com/videosearch.aspx?_keyword=" + $(this)[0].enkey + "&_f=P0S02\" target=\"_blank\" title=\"" + decodeURIComponent($(this)[0].enkey) + "\">" + decodeURIComponent($(this)[0].enkey) + "</a></li>";
                        i++;
                    });
                }
            }
        });
        html += "</ul></div>";
        $("#div_relatedSearch").html(html);
        $("#div_relatedSearch").show();
    }
}
/*播放页热门视频*/
function focusTurn(){
	var i=0,yc=$('.Popular .cover'),l=yc.length,s='';
	function num(){
		yc.parent().find('.page li').removeClass('ac').click(function(){
			clearTimeout(t);
			var _self=$(this);
			_self.addClass('ac');
			i=_self.text()-1;
			g();
			return false;											 
		});
	}
	function g(){
		yc.css('display','none').parent().find('.page li').removeClass('ac');
		if(i<l){
			yc.eq(i).css('display','block').parent().find('.page li:eq('+i+')').addClass('ac');
			i++;
			t=setTimeout(function(){g()},3000);
		}
		else{i=0;g();}
	}
	if(l){num();g();}
}
Pui.callback = function (msg)
{
    alert(msg);
}
Pui.space.video={
	init:function(){
		PUB.Init(); Pui.space.init();Pui.video.init();
	}
}